<template>
  <div>
    <div v-for="it in  formdata.doctorReadPriceDtoList"
         :key='it.id'
         style="width:25%;float:left;margin-bottom:15px;display:flex;align-items:center;">
      <p style="width:200px;text-align:right">
        <span style="color:red">*</span>
        {{it.doctorTitleName}}：
      </p>
      <el-input-number :min="0"
                       :precision="2"
                       :controls="false"
                       v-model="it.price"
                       type="number"
                       placeholder="单位（元）"></el-input-number>
    </div>
    <el-button type="primary"
               @click="onSubmit"
               style="margin-left:4px;margin-top:100px;margin-bottom:10px">保 存</el-button>

  </div>
</template>

<script>
  export default {
    data () {
      return {
        formdata: {
          doctorReadPriceDtoList: [
            { doctorTitleId: '3', doctorTitleName: '主任医师' },
            { doctorTitleId: '4', doctorTitleName: '副主任医师' },
            { doctorTitleId: '6', doctorTitleName: '主治医师' },
            { doctorTitleId: '7', doctorTitleName: '住院医师' },
            { doctorTitleId: '30', doctorTitleName: '公共卫生执业助理医师' },
            { doctorTitleId: '32', doctorTitleName: '公共卫生执业医师' },
          ],
          type: 1
        },

      }
    },
    methods: {
      onSubmit () {
        for (let index = 0; index < this.formdata.doctorReadPriceDtoList.length; index++) {
          const element = this.formdata.doctorReadPriceDtoList[index];
          if (element.price === '' || element.price === null || element.price === undefined) {
            this.$message.warning('请完善价格')
            return
          }
        }
        this.post(this.api.cooperationHospital.doctorReadPriceuploadInfo, this.formdata).then(res => {
          if (res.data.code === '200') {
            this.$message.success(res.data.message)
          } else {
            this.$message.warning(res.data.message)
          }
        })
      }
    },
    mounted () {

      this.post(this.api.cooperationHospital.getDoctorReadPrice, { type: 1 }).then(res => {
        if (res.data.code === '200') {
          if (res.data.object.length) {
            this.formdata.doctorReadPriceDtoList = res.data.object
          }
        } else {
          this.$message.warning(res.data.message)
        }
      })
    }
  }
</script>

<style>
</style>